#include <asm/hwcap.h>
#include <arm_neon.h>
#include <sys/auxv.h>
#include <stdio.h>
#define CPU_IMPLEMENTER_RESERVE                 0x00
#ifndef HWCAP_CPUID
#define HWCAP_CPUID (1<<11)
#endif

static inline uint32_t get_micro_arch_id(void)
{
        uint32_t id=CPU_IMPLEMENTER_RESERVE;
        if ((getauxval(AT_HWCAP) & HWCAP_CPUID)) {
                /** Here will trap into kernel space */
                asm("mrs %0, MIDR_EL1 " : "=r" (id));
        }
        return id&0xff00fff0;
}

int main() {
        uint32_t arch_id = get_micro_arch_id();

        printf("micro arch id: 0x%x\n", arch_id);
        return 0;
}
